clear all
set mem 50m
* cd "..."
use "DATA_COMPILED_ATOP_20151118.dta"
set more off 
 


gen sample1 = 0
replace sample1 = 1 if year <= 2004
label var sample1 "All States"
gen sample2 = 0
replace sample2 = 1 if year <= 2004 & usally == 1 & NATO == 0
label var sample2 "Non-NATO Allies"
gen sample3 = 0
replace sample3 = 1 if year <= 2004 & NATO == 1
label var sample3 "NATO Allies"
gen sample4 = 0
replace sample4 = 1 if year <= 2004 & usally == 0
label var sample4 "Non-Allies"


xtset ccode year

local i = 1

foreach var of varlist sample1-sample4 {

	xtpcse defenseburden l.lntroops l.lntroops_spmean l.interaction l.spatial_lag l.polity l.growth l.lntpop l.IMR l.threat_environment war movav3 borderstates civilwar l.meanregionalallies l.meanregionalusallies if `var'==1 , corr(ar1) pairwise	

	twoway scatter lntroops_spmean lntroops  if e(sample) [w=defenseburden], msymbol(oh) ///
	   xlabel(0(3)15, nogrid ) ///
	   ylabel(0(3)15, nogrid ) ///
	   xtitle("ln(Troops)") ///
	   legend(off) ///
	   ytitle("ln(Troops Spatial Mean)") ///
	   title((`i')) ///
	   graphregion(fcolor(white) lcolor(white)) ///
	   subtitle(`:variable label `var'')

	   graph save `var'.gph, replace


local i = `i'+1

}	   
	   
graph combine sample1.gph sample2.gph sample3.gph sample4.gph, cols(2) xsize(8) ysize(7) ycommon scale(.9) graphregion(color(white))

graph export "Scatterplots_20160203.pdf", replace






